﻿



function Get-Work {
   [CmdletBinding()]
   param(
      [Parameter(Mandatory=$True,
      ValueFromPipelineByPropertyName=$True)]
      [Alias('host')]
      [string[]]$computername
   )
   BEGIN {}
   PROCESS {
      foreach($computer in $computername) {
         someworkerfunction -comptuername $computer
      }
   }
   END {}
}

Function Echo-Pipe {
  Begin {
    # Executes once before first item in pipeline is processed
  }

  Process {
    # Executes once for each pipeline object
    Write-Host $_.Name
  }

  End {
    # Executes once after last pipeline object is processed
  }
}

Function Echo-Pipe2 {
 
   param(
      [Parameter(Mandatory=$True,ValueFromPipeline=$True)]
     
      [object[]]$pipe
   )
   
  Begin {
   $hello="hello"
  }

  Process {
    # Executes once for each pipeline object
   # $counter = $counter+1
    Write-Host $hello ($counter+=1) $_.Name
   # Write-Host $pipe.Name #works!
  }

  End {
    # Executes once after last pipeline object is processed
  }
}


Get-Process | Echo-Pipe2